﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Cinema.aspx.cs" Inherits="TheatreStaff_Cinema" %>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.Configuration" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script type="text/javascript">
        
        function displayCalendar()
        {
            var datePicker = document.getElementById('datePicker');
            datePicker.style.display = 'block';
        }
        function showInsert() {
            var divInsert = document.getElementById('divInsert');
            divInsert.style.display = 'block';
        }
</script>
<script runat ="server" >
        protected void btnOk_Click(object sender, EventArgs e)
        {
            srcCinema.InsertParameters["TheatreId"].DefaultValue = lblId.Text;
        }
</script>
<script type="text/javascript">
function showInsert() {
    var divInsert = document.getElementById('divInsert');
    divInsert.style.display = 'block';
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
</script>
 <style type="text/css">
        #datePicker
        {
            display:none;
            position:absolute;
            border:solid 2px black;
            background-color:white;
           
        }
    
    </style>
<style type="text/css">
#divDisplay
{
    border:solid 1px White;
    width:400px;
    padding:15px;
    margin:0px auto;
    text-align:center;
    border:1px solid #333;
}
#divInsert
{
    display:none;
    border:solid 1px black;
    width:800px;
    position:absolute;
    top:200px;
    left:100px;
    padding:10px;
    background-color:Silver;
    color:Black ;
}
html
{
  background-image:url('image/back.jpg'); 

    padding:10px;
    color:White;    

}

.content
{
           width:950px;
    margin:auto;
        height: 197px;
  
    }

.link
{
  margin-left:350px; 
     font-weight:bold;
  font-size:large;  
    font-size:x-large;
}
.link2
{
  margin-left:50px; 
     font-weight:bold;
  font-size:large;  
    font-size:x-large;
}
a
{
 color: white;
 text-decoration:underline;
 font-weight:bold;

}
a:hover
{
 color: red; 
  text-decoration:none;
  font-weight:bold;

}
.join
{
   background-color:#0099FF;
  clip:auto;
  font-weight:bold;
  font-size:large;
}
.table2
{
 border-style:solid;
   border-color:Black;
   background-color:White;
   color:Black;  
   width:900px; 
}
.row
{
   background-color:Gray;
   color:White;
}
.ticket
{
   background-color:#CC0000;
color:White;

}

.ticket:hover
{
 color: black; 
  text-decoration:none;


}
    .style1
    {
        width: 509px;
    }
    
.footer
{

     font-weight:bold;
  font-size:large;  

}
.ticket1
{
    padding-left:200px;
}
.view2
{
 padding-left:180px;  
 color :white;
}
     .menu
{
 padding-left:140px;  

}
.text
{
 font-weight:bold;
}
.button
{
 margin-left:250px;
}
.view3
{
    padding-left:120px;
}

.footer
{

  margin-top:650px;
}
.center
{
    padding-left:410px;
    
}
.center1
{
    padding-left:320px;
}
.center2
{
    padding-left:0px;
}
.cinema
{
    padding-left:590px;
}
  #footer {

        width: 100%;
        height: 100px;
        top: 250px;
        right: 10;
        bottom: 0;
        left: 0;
      }
     .cinemaList:hover
{
 color: White; background-color:rgba(255,0,0,.75);  font-weight:bold;
}
</style>
    <title>Cinema Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div class="content">
  <asp:Image ID="Image1" Width="1000" Height="130" ImageUrl="~/image/tdk-jun5-bannerbatmanexclusivo2.jpg" runat="server" /><br />
<asp:HyperLink ID="HyperLink14"  CssClass="link" NavigateUrl="~/Default.aspx" runat="server">Home</asp:HyperLink>
<asp:HyperLink ID="HyperLink1"  CssClass="link2" NavigateUrl="~/Session.aspx" runat="server">Session</asp:HyperLink> <asp:HyperLink ID="HyperLink2" CssClass="link2" NavigateUrl="~/Movie.aspx" runat="server">Movies</asp:HyperLink>
<asp:HyperLink ID="HyperLink3" CssClass="link2"  NavigateUrl="~/Price.aspx" runat="server">Prices</asp:HyperLink>


 <br /> <br />
  <%-- <asp:Label ID="Label5" runat="server"  Text="Theatre" CssClass="cinema" Font-Bold="True" Font-Underline="True"></asp:Label>
        <asp:Label ID="Label4" runat="server"  ForeColor="Yellow"></asp:Label>
      
&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp 
          <asp:Label ID="Label3" runat="server" Text="UserName" Font-Bold="True"></asp:Label>    <asp:LoginName ID="LoginName1" runat="server" /> 
    &nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp<asp:LoginStatus ID="LoginStatus1" runat="server" ForeColor="#99CCFF" />--%>
    <table class="center1" >
        <tr>
            <td>
               <asp:Label ID="Label3" runat="server" CssClass="menu" Text="Theatre" Font-Bold="True" Font-Underline="True"></asp:Label>  
            </td>
            <td>
                 <asp:Label ID="Label4" runat="server"  ForeColor="Yellow"></asp:Label> &nbsp;&nbsp;&nbsp;&nbsp;
            </td>
       <%-- </tr>
 </table> --%>
    <%--<td>&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp</td>--%>
<%--&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp --%>
  <%--<table align="center" >
        <tr>--%>
            <td>
                <asp:Label ID="Label04" runat="server" Text="UserName" Font-Bold="True"></asp:Label>
                &nbsp;
            </td>
            <td>
                <asp:LoginName ID="LoginName1" runat="server" /> 
                &nbsp;&nbsp;&nbsp;&nbsp;
            </td>
            <td>
                 <asp:LoginStatus ID="LoginStatus1" runat="server" ForeColor="#99CCFF" />
                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </td>
        </tr>
    </table>

        <hr />
  <asp:Label ID="Label8" runat="server" Text="Maintain:" Font-Bold="True" Font-Size="Larger" Font-Underline="True"></asp:Label>
<asp:HyperLink ID="HyperLink4" runat="server" 
            NavigateUrl="~/TheatreStaff/Cinema.aspx" ForeColor="#FFCC99">[Cinemas]</asp:HyperLink>&nbsp;&nbsp;
    <asp:HyperLink ID="HyperLink5" runat="server"  ForeColor="#FFFF99" NavigateUrl="~/TheatreStaff/Movies.aspx">[Movies]</asp:HyperLink> &nbsp;
    <asp:HyperLink ID="HyperLink144" runat="server" NavigateUrl="~/TheatreStaff/Schedule.aspx" ForeColor="#FF9900">[Schedules]</asp:HyperLink>&nbsp;  
 <asp:HyperLink ID="HyperLink117" runat="server" NavigateUrl="~/TheatreStaff/Session.aspx" ForeColor="#FF6699">[Session Times]</asp:HyperLink>&nbsp;  
  <asp:HyperLink ID="HyperLink116" runat="server" NavigateUrl="~/TheatreStaff/SessionDates.aspx" ForeColor="#66FF66">[Session Date]</asp:HyperLink>&nbsp;   
 <asp:HyperLink ID="HyperLink115" runat="server" NavigateUrl="~/TheatreStaff/SpecialTickets.aspx" ForeColor="Aqua">[Specail Price]</asp:HyperLink>&nbsp;&nbsp;
 <asp:HyperLink ID="HyperLink107" runat="server" NavigateUrl="~/TheatreStaff/specialday.aspx" ForeColor="#CCFF33">[Special Ticket Pricing Days]</asp:HyperLink>&nbsp; 
   <asp:HyperLink ID="HyperLink6" runat="server" NavigateUrl="~/TheatreStaff/SalesReports.aspx" ForeColor="#CCFFFF">[Sales Report]</asp:HyperLink>&nbsp; 
        <asp:HyperLink ID="HyperLink11" runat="server" NavigateUrl="~/TheatreStaff/AddNewUser.aspx" ForeColor="#66FF99">[Add New User]</asp:HyperLink>&nbsp; 
  <hr />
         
             <h3><asp:Label ID="Label2" Text ="Cinema Maintenance" runat="server" CssClass="center" ForeColor="#FFCC99" /></h3>       
        <asp:BulletedList ID="BulletedList1"  CssClass="view2" runat="server">
        <asp:ListItem  Text="Click 'Insert Cinema' to add new cinema" />
        <asp:ListItem Text ="Click 'Cancel' after inserting a new cinema to return to the Cineman Maintenance section" />
        </asp:BulletedList>
         <table align="center"  >
            <tr align ="center" >
                <td><h3><asp:Label ID="Label1" Text ="Add New Cinema"  Visible="false" runat="server" /></h3></td>
            </tr>
            <tr>
                <td>
                  <asp:ScriptManager ID="ScriptManager1" runat="server" />
                   <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                   <ContentTemplate>
                    <asp:GridView ID="grdCinema" 
                    EmptyDataText ="No cinemas added to your theatre" 
                    AutoGenerateColumns ="false" 
                 RowStyle-CssClass="cinemaList"
                     
                    AllowPaging="true"
                    DataSourceID ="srcCinema" 
                    DataKeyNames ="CinemaId"
                     runat ="server" >
                        <Columns >
                         <asp:BoundField DataField ="Cinemaid" HeaderText ="Cinema Number" />
                            <asp:BoundField DataField ="CinemaClassType" HeaderText ="Cinema Class Type" />
                            <asp:BoundField DataField ="CinemaSeatingCapacity" HeaderText ="Cinema Seating Capacity" />
                        </Columns>
                     </asp:GridView> 
                         </ContentTemplate>
                   </asp:UpdatePanel>
             </tr>
             <tr align ="center">
                <td>
                     <a href="JavaScript:showInsert();">Insert Cinema</a>
                   
                </td>
            </tr>
            </table>
         <%-- <table align="center"  >
            <tr>
                <td>--%>
              
               <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                   <ContentTemplate>
               <div id="divInsert"> 
                   
                 <asp:Label ID="lblId" runat="server" Visible="false" ></asp:Label>
                 <%--<asp:Label ID="lblId" runat="server" Visible="true" ></asp:Label>--%>
                    <asp:DetailsView ID="dtlCinema"   DataKeyNames ="CinemaId"  OnItemInserting ="btnOk_Click" DataSourceID ="srcCinema" 
                      AutoGenerateInsertButton ="true" DefaultMode ="Insert"   AllowPaging="false"                     
                       AutoGenerateRows ="False" runat="server"  >
                        <Fields>
                          
                          <asp:BoundField  DataField ="CinemaId" Visible ="false" InsertVisible ="false"/>
                            
                            <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Cinema Class Type">
                               <%-- <ItemTemplate>
                                  <%# Eval("CinemaClassType")%>
                                </ItemTemplate>--%>
                                <InsertItemTemplate>
                                    <asp:DropDownList 
                                    ID="ddlClass" 
                                     DataSourceID ="srcClass" 
                                     DataTextField ="CinemaClassType"
                                     DataValueField ="CinemaClassType"  
                                     SelectedValue='<%# Bind("CinemaClassType") %>'
                                     runat="server" AppendDataBoundItems ="true" >
                                     <asp:ListItem Text ="Select" Value ="-1" />
                                    </asp:DropDownList> 
                                <asp:RequiredFieldValidator
                                    id="reqCinemaClassType"
                                    ControlToValidate="ddlClass"
                                    InitialValue ="-1" 
                                    Text="(Required)"
                                    Runat="server" />
                                </InsertItemTemplate>
                                </asp:TemplateField> 
                                                               
                               <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Cinema Seating Capacity">
                                <%--<ItemTemplate>
                                  <%# Eval("CinemaSeatingCapacity")%>
                                </ItemTemplate>--%>
                                <InsertItemTemplate>
                                  <asp:TextBox
                                    id="txtCinemaSeatingCapacity"
                                    Text='<%# Bind("CinemaSeatingCapacity") %>'
                                    Runat="server" />
                                  <asp:RequiredFieldValidator
                                    id="reqCinemaSeatingCapacity"
                                    ControlToValidate="txtCinemaSeatingCapacity"
                                    Text="(Required)"
                                    Runat="server" />
                                <asp:CompareValidator ID="cmpCinemaCapacity" runat="server"
                                 ErrorMessage="(Please enter a numeric value for seating capacity)"
                                  ControlToValidate ="txtCinemaSeatingCapacity" Type="Integer" Operator="DataTypeCheck"></asp:CompareValidator>       
                                  </InsertItemTemplate>
                               </asp:TemplateField>
                        </Fields>
                         
                    </asp:DetailsView>

      
       </ContentTemplate>
                   </asp:UpdatePanel>
        <asp:SqlDataSource ID="srcCinema" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
       SelectCommand ="SELECT Cinema.CinemaId,Cinema.CinemaClassType, Cinema.CinemaSeatingCapacity FROM Cinema INNER JOIN TheatreStaff ON Cinema.TheatreId = TheatreStaff.TheatreId WHERE (TheatreStaff.TheatreStaffUserName = @username)" 
           InsertCommand  ="INSERT INTO Cinema(TheatreId,CinemaClassType,CinemaSeatingCapacity)
            Values (@TheatreId,@CinemaClassType,@CinemaSeatingCapacity) " 
            DeleteCommand ="DELETE Cinema WHERE CinemaId=@CinemaId">
            <SelectParameters>
                  <asp:Parameter Name ="username" Type ="string"/> 
            </SelectParameters>
            <InsertParameters >
                   <asp:Parameter Name="TheatreId" DbType="Int32"  />
            </InsertParameters>
       </asp:SqlDataSource>
        <asp:SqlDataSource ID="srcClass" runat="server" 
                  ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                  SelectCommand="SELECT DISTINCT CinemaClassType FROM Cinema">
        </asp:SqlDataSource>
          

   <div id="footer"> 
 <table  cellpadding="15" ><tr><td>Copyright@2012 MovieTix</td><td><asp:HyperLink ID="HyperLink8"  CssClass="footer" NavigateUrl="~/Default.aspx" runat="server">Homepage</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink9"  CssClass="footer" NavigateUrl="~/Session.aspx" runat="server">Session</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink10"  CssClass="footer" NavigateUrl="~/Movie.aspx" runat="server">Movies</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink12"  CssClass="footer" NavigateUrl="~/register.aspx" runat="server">Register</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink13"  CssClass="footer" NavigateUrl="~/Login.aspx" runat="server">Log In</asp:HyperLink></td></tr></table>
</div>
 </div>
</form>

</body>
</html>